package com.zhuojy.equity.mall.admin.web.controller.message;

import com.zhuojy.equity.mall.admin.common.entity.bo.TPositionMessageBO;
import com.zhuojy.equity.mall.admin.common.entity.po.TCandidatePO;
import com.zhuojy.equity.mall.admin.common.entity.vo.TPositionMessageVO;
import com.zhuojy.equity.mall.admin.common.pojo.JsonResult;
import com.zhuojy.equity.mall.admin.service.message.TCandidateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:LYL
 * @Date 2024/4/16 16:49
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("TCandidate")
@Api(tags = "候选人模块")
public class TCandidateController {
    @Autowired
    private TCandidateService tCandidateService;

    @ApiOperation(value = "候选人添加", httpMethod = "POST", notes = "候选人添加")
    @RequestMapping("addCandidate")
    public JsonResult addCandidate(@RequestBody TCandidatePO tCandidatePO) {
        try {
            tCandidateService.addCandidate(tCandidatePO);
            return JsonResult.success(200, "添加成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "添加失败！");
        }
    }
    @ApiOperation(value = "候选人模块列表，分页查询", httpMethod = "POST", notes = "候选人模块列表分页查询")
    @RequestMapping("findCandidateFenYe")
    public JsonResult findCandidateFenYe(@RequestBody TCandidatePO tCandidatePO, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return tCandidateService.findCandidateFenYe(tCandidatePO, pageNum, pageSize);
    }
    @ApiOperation(value = "候选人状态修改", httpMethod = "POST", notes = "候选人状态修改")
    @RequestMapping("updateStatusById")
    public JsonResult updateStatusById(@RequestBody TCandidatePO tCandidatePO) {
        try {
            tCandidateService.updateStatusById(tCandidatePO);
            return JsonResult.success(200, "修改成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "修改失败！");
        }
    }

    @ApiOperation(value = "候选人回显", httpMethod = "POST", notes = "候选人回显")
    @RequestMapping("findCandidateById")
    public TCandidatePO findCandidateById(Long id){
        return tCandidateService.findCandidateById(id);
    }
}
